/************************************************************************
<4loco-aprs.  This program connects to a specified APRS server and displays
    the information on a map. It's being developed using QT Creator. The project
    began in February and version 1 should be released in April. For more
    information go to http://code.google.com/p/4loco-aprs/>

    Copyright (C) <2011>  <Kyle Roden, Glen Riden, Aaron Smith, Alisa Emerich>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#include "stationsettings.h"
#include "ui_stationsettings.h"

#include <QString>
#include <QPoint>
#include <QMouseEvent>
#include <QDebug>

stationsettings::stationsettings(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::stationsettings)
{
    ui->setupUi(this);
    this->setFixedSize(size());


}

stationsettings::~stationsettings()
{
    delete ui;
}

void stationsettings::mousePressEvent(QMouseEvent *e)
{
    qDebug()<<"mouse clicked";

    QPoint pressPos;


    if(e->buttons() == Qt::LeftButton){

        pressPos = e->pos()-this->ui->label->pos();
        int unique = pressPos.x()/21+(pressPos.y()/21)*100;
        char symbol = getchar(unique);
        if((symbol=='\a'))
            return;
        emit symbolSelected(symbol);
        close();
    }
}


char stationsettings::getchar(int unique){

    switch(unique){
    case 0:return('!'); break;
    case 1:return('"'); break;
    case 2:return('#'); break;
    case 3:return('$'); break;
    case 4:return('%'); break;
    case 5:return('&'); break;
    case 6:return('\''); break;
    case 7:return('('); break;
    case 8:return(')'); break;
    case 9:return('*'); break;
    case 10:return('+'); break;
    case 11:return(','); break;
    case 12:return('-'); break;
    case 13:return('.'); break;
    case 14:return('/'); break;
    case 15:return('0'); break;
    case 100:return('1'); break;
    case 101:return('2'); break;
    case 102:return('3'); break;
    case 103:return('4'); break;
    case 104:return('5'); break;
    case 105:return('6'); break;
    case 106:return('7'); break;
    case 107:return('8'); break;
    case 108:return('9'); break;
    case 109:return(':'); break;
    case 110:return(';'); break;
    case 111:return('<'); break;
    case 112:return('='); break;
    case 113:return('>'); break;
    case 114:return('?'); break;
    case 115:return('@'); break;
    case 200:return('A'); break;
    case 201:return('B'); break;
    case 202:return('C'); break;
    case 203:return('D'); break;
    case 204:return('E'); break;
    case 205:return('F'); break;
    case 206:return('G'); break;
    case 207:return('H'); break;
    case 208:return('I'); break;
    case 209:return('J'); break;
    case 210:return('K'); break;
    case 211:return('L'); break;
    case 212:return('M'); break;
    case 213:return('N'); break;
    case 214:return('O'); break;
    case 215:return('P'); break;
    case 300:return('Q'); break;
    case 301:return('R'); break;
    case 302:return('S'); break;
    case 303:return('T'); break;
    case 304:return('U'); break;
    case 305:return('V'); break;
    case 306:return('W'); break;
    case 307:return('X'); break;
    case 308:return('Y'); break;
    case 309:return('Z'); break;
    case 310:return('['); break;
    case 311:return('\\'); break;
    case 312:return(']'); break;
    case 313:return('^'); break;
    case 314:return('_'); break;
    case 315:return('`'); break;
    case 400:return('a'); break;
    case 401:return('b'); break;
    case 402:return('c'); break;
    case 403:return('d'); break;
    case 404:return('e'); break;
    case 405:return('f'); break;
    case 406:return('g'); break;
    case 407:return('h'); break;
    case 408:return('i'); break;
    case 409:return('j'); break;
    case 410:return('k'); break;
    case 411:return('l'); break;
    case 412:return('m'); break;
    case 413:return('n'); break;
    case 414:return('o'); break;
    case 415:return('p'); break;
    case 500:return('q'); break;
    case 501:return('r'); break;
    case 502:return('s'); break;
    case 503:return('t'); break;
    case 504:return('u'); break;
    case 505:return('v'); break;
    case 506:return('w'); break;
    case 507:return('x'); break;
    case 508:return('y'); break;
    case 509:return('z'); break;
    case 510:return('{'); break;
    case 511:return('|'); break;
    case 512:return('}'); break;
    case 513:return('~'); break;
    default: return('\a');

    }

}

